package com.design.factory;

public class AbstractFactory implements IFactory{

    @Override
    public IBean get(Type type) {
        return getFactory(type).get(type);
    }

    public IFactory getFactory(IFactory.Type type) {
        switch (type) {
            case A:
                return new FactoryA();
            case B:
                return new FactoryB();
            default:
                return null;
        }
    }

    public static class FactoryA implements IFactory {
        @Override
        public IBean get(Type type) {
            return new IBean.BeanA();
        }
    }
    public static class FactoryB implements IFactory {
        @Override
        public IBean get(Type type) {
            return new IBean.BeanB();
        }

    }
}
